/*
 * SegmentPort.cpp
 *
 * IOPort that interfaces with the athena board for the
 * segments of the seven segment display
 *
 * Author: Zachary Masiello
 * Author: Peter-John Rowe
 */
#include "SegmentPort.h"

#define ZERO 0xC0
#define ONE 0xF9
#define TWO 0xA4
#define THREE 0xB0
#define FOUR 0x99
#define FIVE 0x92
#define SIX 0x82
#define SEVEN 0xF8
#define EIGHT 0x80
#define NINE 0x90
#define NONE 0xFF
//With Decimals after
#define ZEROD 0x40
#define ONED 0x79
#define TWOD 0x24
#define THREED 0x30
#define FOURD 0x19
#define FIVED 0x12
#define SIXD  0x02
#define SEVEND 0x78
#define EIGHTD 0x00
#define NINED 0x10
#define NONED 0x7F

SegmentPort::SegmentPort() : IOPort(1, 0x288)
{

}

SegmentPort::~SegmentPort()
{
	// TODO Auto-generated destructor stub
}

/*
 * 1-9 = 1-9;
 * 10, 20, 30... = 1. 2. 3. ...
 * 11 = 0.
 * 12 = blank
 * 13 = .
 */
void SegmentPort::output(int number)
{
	switch(number)
	{
	case 0:
		out8(_portHandle, ZERO);
		break;
	case 1:
		out8(_portHandle, ONE);
		break;
	case 2:
		out8(_portHandle, TWO);
		break;
	case 3:
		out8(_portHandle, THREE);
		break;
	case 4:
		out8(_portHandle, FOUR);
		break;
	case 5:
		out8(_portHandle, FIVE);
		break;
	case 6:
		out8(_portHandle, SIX);
		break;
	case 7:
		out8(_portHandle, SEVEN);
		break;
	case 8:
		out8(_portHandle, EIGHT);
		break;
	case 9:
		out8(_portHandle, NINE);
		break;
	case 11:
		out8(_portHandle, ZEROD);
		break;
	case 12:
		out8(_portHandle, NONE);
		break;
	case 13:
		out8(_portHandle, NONED);
		break;
	case 10:
		out8(_portHandle, ONED);
		break;
	case 20:
		out8(_portHandle, TWOD);
		break;
	case 30:
		out8(_portHandle, THREED);
		break;
	case 40:
		out8(_portHandle, FOURD);
		break;
	case 50:
		out8(_portHandle, FIVED);
		break;
	case 60:
		out8(_portHandle, SIXD);
		break;
	case 70:
		out8(_portHandle, SEVEND);
		break;
	case 80:
		out8(_portHandle, EIGHTD);
		break;
	case 90:
		out8(_portHandle, NINED);
		break;
	}

}
